//
//  CLgoViewController.m
//  I-want-go
//
//  Created by dllo on 15/11/9.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "CLgoViewController.h"
#import "CLscreen.h"
#import "BaseModel.h"
#import "AppDelegate.h"
@interface CLgoViewController ()<UIScrollViewDelegate>
@property(nonatomic, retain)UIScrollView *scrollView;
@property(nonatomic, retain)NSArray *picArr;
@property(nonatomic, retain)UIPageControl *page; // 页面控制
@end

@implementation CLgoViewController

- (void)dealloc
{
    [_picArr release];
    [_page release];
    [_scrollView release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.picArr = @[@"go1.png", @"go2.png", @"go3.png"];
    
    [self createScrollView];
}

- (void)createScrollView {
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
    _scrollView.contentSize = CGSizeMake(375 *SWIDTH * _picArr.count, 0);
    _scrollView.pagingEnabled = YES;
    [self.view addSubview:_scrollView];
    [_scrollView release];
    _scrollView.delegate = self;
    
    
    for (NSInteger i = 0; i < 3; i++ ) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((375 *SWIDTH) * i, 0, 375 * SWIDTH, 667 * SHEIGHT)];
        imageView.image = [UIImage imageNamed:_picArr[i]];
        [_scrollView addSubview:imageView];
        [imageView release];
    }
    
}





- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat offsetX = self.scrollView.contentOffset.x;
    if (offsetX > (375 * SWIDTH) * 2) {
        
        AppDelegate *appVC = (AppDelegate *)[[UIApplication sharedApplication]delegate];
        [[UIApplication sharedApplication].keyWindow setRootViewController:appVC.tab];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
